package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class Return implements IOperation{
    @Override
    public void work (BookList bookList) {
        System.out.println ("归还图书");

        System.out.println ("输入要归还的书名：");
        Scanner p=new Scanner (System.in);
        String name=p.nextLine ();

        int current=bookList.getUsedSize ();
        for (int i = 0; i < current; i++) {
            Book b=bookList.getBooks (i);
            if(b.getName ().equals (name)){
                b.setB0rrowed (false);
                System.out.println ("已经归还");
                return;
            }
        }

        System.out.println ("不存在这本要归还的书");
    }
}
